# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#作者：cacho_37967865
#博客：https://blog.csdn.net/sinat_37967865
#文件：requests_model.py
#日期：2023-12-31
#备注：requests 请求类型，参数类型，返回类型 https://api.pearktrue.cn/
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
import requests
from pycacho.cachobase.file_deal import save_file,get_file
from pycacho.cachobase.deal_json import dict_to_json


def post_form_data(file):
    headers = {'Content-Type': 'multipart/form-data'}
    url = "https://api.pearktrue.cn/api/ocr/?"
    response = requests.post(url, files={'file':("ye.png",get_file(file))}, headers=headers)
    print(response.text)

# 万能短视频解析
def get_json(video_url):
    url = "https://api.pearktrue.cn/api/video/api.php?url="+video_url
    response = requests.post(url)
    print(response.status_code)  # 获取响应状态码
    print(response.headers)      # 获取响应头
    print(response.text)      # 获取响应文本内容
    print(response.content)      # 获取响应字节内容
    dict_to_json(response.json())

# 获取图片
def get_image():
    url = "https://api.pearktrue.cn/api/captcha/?type=create"
    response = requests.get(url)
    save_file('F:\PythonProject\\create.jpg', response.content)

# 历史上的今天
def get_text():
    url = "https://api.pearktrue.cn/api/lsjt/?type=json"
    response = requests.get(url)
    dict_to_json(response.json())

if __name__ == '__main__':
    #post_form_data("F:\PythonProject\machinelearn\ocr\\ye.png")
    #get_json("https://v.douyin.com/634msgx/")
    #get_image()
    get_text()